package com.heima.utils.thread;

import com.heima.model.user.pojos.ApUser;

/**
 * @Author: xrl
 * @Date: 2022/10/14  22:12
 * @Version 1.0
 */
public class AppThreadLocalUtil {
    private final  static ThreadLocal<ApUser> AP_USER_THREAD_LOCAL = new ThreadLocal<>();

    //存入线程
    public static void setUser(ApUser apUser) {
        AP_USER_THREAD_LOCAL.set(apUser);
    }

    //从线程中取出
    public static ApUser getUser() {
        return AP_USER_THREAD_LOCAL.get();
    }

    //从线程中清理掉
    public static void clear() {
        AP_USER_THREAD_LOCAL.remove();
    }
}
